package com.qf.controller;



import com.qf.pojo.Inventory;

import com.qf.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/*后台库存管理*/
@RestController
@RequestMapping("/inventory")
public class InventoryController {
    @Autowired
    InventoryService inventoryService;
    @RequestMapping("/findAll")
    public List<Inventory> findAll(){
        System.out.println("++++++++++++");
        List<Inventory> all = inventoryService.findAll();
        for (int i=0;i<all.size();i++){
            System.out.println(all.toString());
        }
        return all;
    }

    @RequestMapping("/findById")
    public Inventory findById( Inventory inventory ){

        return inventoryService.findById(inventory);
    }

    @RequestMapping("/insert")
    public String insert(@RequestBody Inventory inventory){
        inventoryService.insert(inventory);
        return "success";
    }

    @RequestMapping("/update")
    public String update(@RequestBody Inventory inventory){
        inventoryService.update(inventory);
        return "success";
    }

    @RequestMapping("/delete")
    public String delete(Integer id){
        inventoryService.delete(id);
        return "success";
    }
}
